import { USER_TOKEN } from './action-type'

export default {
  //设置用户token
  setUserToken(state, data) {
    state[USER_TOKEN] = data
  },
  //设置用户信息
  setUserInfo(state, data) {
    state.userInfo = data
  },
  //清除用户token和信息
  removeUser(state) {
    state[USER_TOKEN] = null,
    state.userInfo = {}
  },
  //添加路由缓存组件
  addCachePages(state, name) {
    if(!state.cachePages.includes(name)) {
      state.cachePages.push(name)
    }
  },
  //移除缓存组件
  removeCachePage(state, name) {
    const index = state.cachePages.indexOf(name)
    if(index !== -1){
      state.cachePages.splice(index, 1)
    }
  }

}